/**
 * @desc 防抖函数
 * @demo 183-7983-6654 
 * @param func 方法
 * @param delay 间隔秒数
 * */
export const debounce = (func, delay) => {
	let timer;
	return function() {
		const context = this;
		const args = arguments;
		clearTimeout(timer);
		timer = setTimeout(() => {
			func.apply(context, args);
		}, delay);
	}
}


// 根据url获取参数
export const getQueryString = (name, str) => {
	if (!str) {
		return null
	}
	let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
	let r = str.match(reg)
	if (r != null) {
		return unescape(r[2])
	}
	return null
}

// 判断是不是微信浏览器
export const isWeixin = (name, str) => {
	let ua = navigator.userAgent.toLowerCase();
	return ua.indexOf('micromessenger') != -1;
}